//
//  FlutterMapControllerRegister.m
//  amap_flutter_map
//
//  Created by 伊小洛 on 2023/12/5.
//

#import <Foundation/Foundation.h>
#import "FlutterMapControllerRegister.h"

@implementation FlutterMapControllerRegister {
    id<FlutterMapControllerProtocol>(^ _builder)(NSInteger);
}

+ (instancetype)shared {
    static FlutterMapControllerRegister *instance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [FlutterMapControllerRegister.alloc init];
    });
    return instance;
}

- (nullable id<FlutterMapControllerProtocol>)buildMapController {
    if (_builder != nil) {
        return _builder(0);
    }
    return nil;
}

- (nullable id<FlutterMapControllerProtocol>)buildMapControllerWithType:(NSInteger)type {
    if (_builder != nil) {
        return _builder(type);
    }
    return nil;
}

- (void)registerBuilder: (id<FlutterMapControllerProtocol>(^)(NSInteger))builder {
    _builder = builder;
}


@end
